#!/usr/bin/python
#coding: utf-8

import sys
sys.path.append("..")

import logging
import logging.handlers

LOG_FILE = r'C:\Users\Administrator\Desktop\Task_Sql\Logging\app_logger.log'

handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=5)  # 实例化handler
fmt = '%(asctime)s - %(filename)s:%(lineno)s - %(name)s - %(message)s'

formatter = logging.Formatter(fmt)  # 实例化formatter
handler.setFormatter(formatter)  # 为handler添加formatter

logger = logging.getLogger('app_logger')  # 获取名为task的logger
logger.addHandler(handler)  # 为logger添加handler
logger.setLevel(logging.DEBUG) # 设置日志的等级

def log_Main(*args):
    if args[-1] == "info":
        logger.info(args[0])
    elif args[-1] == "error":
        logger.error(args[0])
    elif args[-1] == "warning":
        logger.warning(args[0])
    elif args[-1] == "critical":
        logger.critical(ags[0])
    elif args[-1] == "debug":
        logger.debug(args[0])
    elif args[-1] == "notset":
        logger.notset(args[0])